/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.oracleandsxnd.erp.member.web;

import com.oracleandsxnd.erp.common.persistence.Page;
import com.oracleandsxnd.erp.common.persistence.TableSplitResult;
import com.oracleandsxnd.erp.common.web.AjaxResult;
import com.oracleandsxnd.erp.common.web.BaseController;
import com.oracleandsxnd.erp.member.entity.Member;
import com.oracleandsxnd.erp.member.entity.MemberIntegralGive;
import com.oracleandsxnd.erp.member.service.MemberIntegralGiveService;
import com.oracleandsxnd.erp.member.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 会员积分赠送管理Controller
 * @author 会员积分赠送管理
 * @version 2019-12-13
 */
@Controller
@RequestMapping(value = "member_memberIntegralGive")
public class MemberIntegralGiveController extends BaseController {

	@Autowired
	private MemberIntegralGiveService memberIntegralGiveService;
	@Autowired
	private MemberService memberService;
	@RequestMapping(value = {""})
	public String list(MemberIntegralGive memberIntegralGive, HttpServletRequest request, HttpServletResponse response, Model model) {
		List<Member> memberCategorys= memberService.findList(new Member());
		model.addAttribute("members",memberCategorys);
		return "erp/member/memberIntegralGiveList";
	}

	@RequestMapping(value = {"listData"})
	@ResponseBody
	public Object listData(MemberIntegralGive memberIntegralGive , HttpServletRequest request, HttpServletResponse response){
		Page<MemberIntegralGive> page = memberIntegralGiveService.findPage(new Page<MemberIntegralGive>(request, response), memberIntegralGive);
		TableSplitResult<MemberIntegralGive> result=new TableSplitResult<MemberIntegralGive>(page.getPageNo(), page.getCount(), page.getList());
		return  result;
	}
	@RequestMapping(value = "save")
	@ResponseBody
	public AjaxResult save(MemberIntegralGive memberIntegralGive) {

		try {
			memberIntegralGiveService.save(memberIntegralGive);
		} catch (Exception e) {
			e.printStackTrace();
			return  error(e.getMessage());
		}
		return success();
	}




}